package _6ShiPeiQi.adapter;

import _6ShiPeiQi.AdvancedMediaPlayer;
import _6ShiPeiQi.MediaPlayer;
import _6ShiPeiQi.impl.Mp4Player;
import _6ShiPeiQi.impl.VlcPlayer;

/**
 * @MediaAdapter: MediaPlay接口 适配器
 * @author: ZBoHang
 * @time: 2021/9/7 14:16
 */
public class MediaAdapter implements MediaPlayer {

    private AdvancedMediaPlayer advancedMediaPlayer;

    public MediaAdapter(String audioType) {
        if ("vlc".equalsIgnoreCase(audioType)) {
            advancedMediaPlayer = new VlcPlayer();
        }
        if ("mp4".equalsIgnoreCase(audioType)) {
            advancedMediaPlayer = new Mp4Player();
        }
    }

    @Override
    public void play(String audioType, String fileName) {
        if ("vlc".equalsIgnoreCase(audioType)) {
            advancedMediaPlayer.playVlc(fileName);
        }
        if ("mp4".equalsIgnoreCase(audioType)) {
            advancedMediaPlayer.playMp4(fileName);
        }
    }
}
